import { defineConfig, presetAttributify, presetUno, presetIcons } from 'unocss';

const remRE = /(-?[\.\d]+)rem/g
export default defineConfig({
  presets: [
    presetUno({
      pipeline: {
        include: ["nvue"]
      }
    }),
    // presetAttributify(),
    // presetIcons(),
  ],
  rules: [
    [/^inset-(\d+)$/, ([, d]) => ({ top: `${+d}rpx`, right: `${+d}rpx`, bottom: `${+d}rpx`, left: `${+d}rpx` })],
  ],
  shortcuts: [
    ['wh-full', 'w-full h-full'],
  ],
  postprocess: [
    obj => obj.entries.forEach((i) => {
      const value = i[1];
      if (typeof value === 'string' && remRE.test(value)) {
        i[1] = value.replace(remRE, (_, p1) => `${(p1 * 4)}rpx`);
      }
    }),
  ]
})
